﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Control;
using Model;

namespace BioBooking
{
    public partial class FindDelete : Form
    {
        private BookingController bookingCtr;

        public FindDelete()
        {
            InitializeComponent();
            bookingCtr = new BookingController();
        }

        private void findButton_Click(object sender, EventArgs e)
        {
            bookingsListBox.DataSource = bookingCtr.FindBookings(phoneTxtBox.Text);
        }

        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (bookingsListBox.SelectedIndex != -1)
            {
                int rc = bookingCtr.DeleteBooking((Booking)bookingsListBox.SelectedItem);
                if (rc == 1)
                {
                    MessageBox.Show("Booking blev slettet");
                    bookingsListBox.DataSource = bookingCtr.FindBookings(phoneTxtBox.Text);
                }
                else
                {
                    MessageBox.Show("Fejl ikke slettet.");
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
